//调整数组使奇数全部都位于偶数前面。
#include<assert.h>
#include<string.h>
void sweap(int* a, int* b)
{
	int tmp = 0;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void Sort(int* p,int sz)
{
	assert(p);
	int left = 0;
	int right = sz ;
	if ((sz+1) % 2==0)
	{
		left += 1;
		right -= 1;
	}
	else
	{
		left++;
	}
	while (left < right)
	{
		sweap(p + left, p + right);
		left += 2;
		right -= 2;
	}
}

int main()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9 };
	int len = sizeof(arr) / sizeof(int);
	Sort(arr,len-1);
	for (int i = 0; i < len; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}


//模拟实现库函数strcpy
char* my_strcpy(char* des,const char* sour)
{
	assert(des && sour);
	char* p = des;

	while (*des++ = *sour++)
	{
		;
	}
	return p;
}



//模拟实现库函数strlen
#include<assert.h>
 unsigned my_strlen(const char* str)
{
	assert(str);
	int count = 0;
	while (*str++)
	{
		count++;
	}
	return count;
}




